package com.xnfh.framework.utils

import android.util.Log
import com.xnfh.framework.Constants
import java.util.UUID

/**
 * @Description:生成唯一标识
 * @author ziheng
 * @date 2022/12/22 15:46
 */
object UuidUtils {

    private const val TAG = "UuidUtils"

    /**
     * 生成uuid
     */
    fun randomUuid(): String {
        var randomUUID = KVUtil.getString(Constants.USER_CLENT_UUID,null)
        if(randomUUID == null){
            randomUUID = UUID.randomUUID().toString()
            Log.i(TAG, "randomUuid: ${randomUUID}")
            KVUtil.put(Constants.USER_CLENT_UUID,"client_${randomUUID}")
        }
        return randomUUID
    }

    /**
     * 获取uuid
     */
    fun getUuid(): String{
        val uuid = KVUtil.getString(Constants.USER_CLENT_UUID)
        if(uuid != null){
            return uuid
        }
        return randomUuid()
    }



}